home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / lang_c / cug106 / xtrinslb.mac < prev    next >
Text File  |  1984-06-14  |  3KB  |  153 lines

  1.     title    Xtract field from and insert field into buffer
  2.     name    ('XTRINS')
  3.     ;
  4.     ; This is intended for use with Microsoft 'M80' and 'L80'
  5.     ;
  6.     .xlist    ; turn off listing
  7.     .xcref    ; turn off cross reference label 'reference' accumulation
  8.     ;
  9.     ;
  10. @CHK    macro    ?DD    ;; Used for checking range of 8-bit displacements
  11.     if (?DD gt 7FH) and (?DD lt 0FF80H)
  12.       'Displacement Range Error - TDL LIB'    ;;force an error
  13.     endif
  14.     endm
  15.     ;
  16. LDED    macro    ?NNNN    
  17.       db    0EDH,5BH
  18.       dw    ?NNNN
  19.     endm
  20.     ;
  21. LBCD    macro    ?NNNN    
  22.       db    0EDH,4BH
  23.       dw    ?NNNN
  24.     endm
  25.     ;
  26.     ;
  27. BIT    macro    ?N,?R    
  28.       db    0CBH,?N*8+?R+40H
  29.     endm
  30.     ;
  31. SETB    macro    ?N,?R
  32.       db    0CBH,?N*8+?R+0C0H
  33.     endm
  34.     ;
  35. RES    macro    ?N,?R
  36.       db    0CBH,?N*8+?R+80H
  37.     endm
  38.     ;
  39.     ;
  40. JMPR    macro    ?N
  41.       db    18H,?N-$-1
  42.     endm
  43.     ;
  44. JRC    macro    ?N
  45.       db    38H,?N-$-1
  46.     endm
  47.     ;
  48. JRNC    macro    ?N
  49.       db    30H,?N-$-1
  50.     endm
  51.     ;
  52. JRZ    macro    ?N
  53.       db    28H,?N-$-1
  54.     endm
  55.     ;
  56. JRNZ    macro    ?N
  57.       db    20H,?N-$-1
  58.     endm
  59.     ;
  60. DJNZ    macro    ?N
  61.       db    10H,?N-$-1
  62.     endm
  63.     ;
  64.     ;
  65. RLCR    macro    ?R    
  66.       db    0CBH, 00H + ?R
  67.     endm
  68.     ;
  69. RALR    macro    ?R    
  70.       db    0CBH, 10H+?R
  71.     endm
  72.     ;
  73. RRCR    macro    ?R    
  74.       db    0CBH, 08H + ?R
  75.     endm
  76.     ;
  77. RARR    macro    ?R    
  78.       db    0CBH, 18H + ?R
  79.     endm
  80.     ;
  81. SLAR    macro    ?R    
  82.       db    0CBH, 20H + ?R
  83.     endm
  84.     ;
  85. SRAR    macro    ?R    
  86.       db    0CBH, 28H+?R
  87.     endm
  88.     ;
  89. SRLR    macro    ?R    
  90.       db    0CBH, 38H + ?R
  91.     endm
  92.     ;
  93.     ;
  94.     ;
  95.     .cref    ; re-enable cross reference 
  96.     .list    ; re-enable listing
  97.     ;
  98.     ;
  99.     ;++ **************************************************
  100.     ;
  101.     ; TO USE THIS ROUTINE:
  102.     ;
  103.     ;    M80 XTRINSLB=XTRINSLB        ...Microsoft 'M80'
  104.     ;    L80 XTRINSLB,XTRINSLB/N/E    ...Microsoft 'L80'
  105.     ;    REN BIOS.CRL=BIOS.COM
  106.     ;
  107.     ;    XTRINSLB.CRL WILL BE A 'C' COMPATIBLE RELOCATABLE FILE
  108.     ;    WHICH CAN BE REQUESTED AT CLINK OR INTEGRATED
  109.     ;    INTO YOUR LIBRARY WITH CLIB
  110.     ;
  111.     ;-- **************************************************
  112.     ;
  113. MAGIC    equ    3F7H        ;'C' PARAMETER PASSING BUFFER
  114.     ;
  115.     aseg
  116.     org    100H
  117.     .phase    0
  118.     ;
  119. ZERO:    dc    'INSERT'    ; Name of insert function
  120.     dw    INSHEAD        ; Location of insert function
  121.     dc    'XTRACT'    ; Name of xtract function
  122.     dw    XTRHEAD        ; Location of xtract function
  123.     ;
  124.     db    80H        ;END OF DIRECTORY ENTRIES
  125.     dw    FINIS - 100H    ;POINTER TO NEXT AVAIL LOCATION IN FILE
  126.     ds    (512 -($-ZERO))    ;PAD REST OF DIRECTORY
  127.     ds    5        ;RESERVED FOR 'CLIB'
  128.     ;
  129.     .dephase
  130.     ;
  131.     page
  132.     ;
  133.     ;++ ****************************************
  134.     ;
  135.     ;$$ INSERT    -- Insert bit field into a byte array
  136.     ;
  137.     ;    Bits are numbered 1..N
  138.     ;    Width may be 1..16
  139.     ;
  140.     ;    Storage format is:
  141.     ;
  142.     ;           msb    lsb
  143.     ;
  144.     ;        8      1    first byte of array
  145.     ;           16      9
  146.     ;        .      .
  147.     ;        .      .
  148.     ;        N      N-8    last byte of array
  149.     ;
  150.     ; insert(array,data,start,width)
  151.     ;    char *array;
  152.     ;    unsigned data;
  153.     ;    char